package top.leyi.handle;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.leyi.IService.IAttenService;
import top.leyi.entity.user.User;
import top.leyi.utils.Result;
import top.leyi.utils.ResultGenerator;

@RestController
@RequestMapping("/api/attention")
public class AttenHandle {
   @Autowired
    IAttenService attenService;
   @GetMapping("")
    public Result<User> getAllFans(@RequestParam("token") String token,
                                   @RequestParam("id") int id){
       return new Result(200, attenService.getAlFans(id));
   }
    @GetMapping("/v")
    public Result<User> getAllV(@RequestParam("token") String token,
                                   @RequestParam("id") int id){
        return new Result(200, attenService.getAllV(id));
    }

    @PostMapping("")
    public Result<User> addAtten(@RequestParam("token") String token,
                                 @RequestParam("vId") int vId,
                                 @RequestParam("id") int fansId){
        attenService.attenOne(vId, fansId);
        return ResultGenerator.OK.getResult();
    }

    @DeleteMapping("")
    public Result<User> cancelAtten(@RequestParam("token") String token,
                                   @RequestParam("vId") int vId,
                                   @RequestParam("id") int fansId){
        attenService.cancelAtten(vId, fansId);
        return ResultGenerator.OK.getResult();
    }

}
